export const formatDate = (date) => {
  if (!(date instanceof Date)) {
    date = new Date(date);
  }
  return date.getFullYear() + '/' + 
         String(date.getMonth() + 1).padStart(2, '0') + '/' + 
         String(date.getDate()).padStart(2, '0') + ' ' + 
         String(date.getHours()).padStart(2, '0') + ':' + 
         String(date.getMinutes()).padStart(2, '0') + ':' + 
         String(date.getSeconds()).padStart(2, '0');
};

export const formatDuration = (duration) => {
  return new Date(duration).toISOString().slice(11, 19);
};

export const calculateDurationInMinutes = (startTime, endTime) => {
  const start = new Date(startTime);
  const end = new Date(endTime);
  return Number(((end - start) / 1000 / 60).toFixed(2));
};
